在 Jenkins Windows Agent 节点上执行 Shell 命令 |
您所在的位置:网站首页 › jenkins shell脚本 › 在 Jenkins Windows Agent 节点上执行 Shell 命令 |
Jenkins 在 Windows agent 上执行shell 命令,听起来很有意思,以下方法可以在 Jenkins 中执行一些简单的 shell 脚本,如果是复杂脚本就交给 Linux agent 去做吧。 1. 安装工具(二选一)- Git bash - Cygwin 由于我用Git, 所以我安装的是Git for Windows. https://git-scm.com/download/win 2. 加入环境变量PATH把 Git bash 命令的路径加入环境变量, 例如:“C:\Program Files\Git\usr\bin”\ 备注:如果不想加环境变量,可以到 Jenkins -> Manage -> Configure 中去设置 shell executable 3. 配置Jenkins Job接下来就可以在 job 中增加 execute shell script, 可以用 freestyle job 也可以用 pipeline 的 sh 'xxx'. 已知问题在执行一些带路径的 shell 命令时,路径会被解析成 Windows 风格,导致命令出错。 如: cp ${WORKSPACE}/test.txt .${WORKSPACE}/test.txt 会解析成:"C:\Jenkins/test.txt", 导致命令出错。我的解决方法是 cd 或者 pushd ${WORKSPACE} 再进行相应操作。
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |